<?php

namespace app\command;

use app\admin\model\base\SysConfig;
use app\datacenter\service\StatisticsService;
use think\console\Command;
use think\console\Input;
use think\console\Output;

/**
 * 出袋统计(每小时统计一次)
 */
class DatacenterStatistics extends Command
{
    protected function configure()
    {
        $this->setName('DatacenterStatistics')->setDescription('出袋统计');
    }

    protected function execute(Input $input, Output $output)
    {
        //加载系统配置
        SysConfig::loadConfig();
        //执行统计
        $StatisticsService = new StatisticsService();
        $res = $StatisticsService->outBagStatistics('sbs');
        $msg = date('Y-m-d H:i:s') . '定时任务执行失败！';
        if ($res) $msg = date('Y-m-d H:i:s') . '定时任务执行成功！';
        $output->writeln($msg);
        die;
    }
}